<template>
<view class="flex-yh">
  <Header><view class="header">{{title}}</view></Header>
  <index-default v-if="selectedIndex == 0"></index-default>
  <index-material v-if="selectedIndex == 1"></index-material>
  <index-template v-if="selectedIndex == 3"></index-template>
  <index-my v-if="selectedIndex == 4"></index-my>
  <TabBar :selected.sync="selectedIndex"></TabBar>
</view>
</template>
<script>
import indexDefault from './index-default';
import indexMaterial from './index-material';
import indexTemplate from './index-template';
import indexMy from './index-my';
import config from "@/common/config";
import {phoneFalg} from "@/common/utils";
export default {
	components:{indexDefault,indexMaterial,indexTemplate,indexMy},
	data() {
		return {
			title:'这是一个标题',
			selectedIndex:0
		}
	},
	onLoad() {
    console.log('bbb-store',this.$store.state.token)
    uni.$on('mqttMsg', this.dealMsg)
    console.log('首页-->onLoad');
    this.getData();
	},
	methods: {
		dealMsg(res){
			console.log('我要更新一条新数据',res);
		},
		async getData(){
			var _param = {
				url:config.getNav
			}
			var data = await this.$http(_param);	
			console.log(data);
		}
	}
}
</script>

<style>
.header{ background: red; flex:1; display:flex; align-items:center;}
.box{ background: #ccc; flex:1; min-height: 100rpx; overflow: auto;}
</style>
